package com.huawei.mpchartdemo1;

import android.os.Bundle;

import androidx.appcompat.app.AppCompatActivity;

import com.github.mikephil.charting.charts.ScatterChart;
import com.github.mikephil.charting.components.XAxis;
import com.github.mikephil.charting.components.YAxis;
import com.github.mikephil.charting.data.Entry;
import com.github.mikephil.charting.data.ScatterData;
import com.github.mikephil.charting.data.ScatterDataSet;

import java.util.ArrayList;
import java.util.List;

public class ScatterChartActivity extends AppCompatActivity {

    private ScatterChart scatterChart;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_scatter_chart);
        initView();
        scatterChart.getDescription().setEnabled(false);
//        YAxis yl = scatterChart.getAxisLeft();
//        yl.setAxisMinimum(0f);
        scatterChart.getAxisRight().setEnabled(false);
//        XAxis xl = scatterChart .getXAxis();
//        xl.setDrawGridLines(false);
        List<Entry> list = new ArrayList<>();
        list.add(new Entry(0, 3));
        list.add(new Entry(1, 10));
        list.add(new Entry(2, 5));
        list.add(new Entry(3, 8));
        list.add(new Entry(4, 2));
        list.add(new Entry(5, 3));
        ScatterDataSet set1 = new ScatterDataSet(list, "list");
        ScatterData data = new ScatterData(set1);
        scatterChart.setData(data);
        scatterChart.invalidate();
    }

    private void initView() {
        scatterChart = (ScatterChart) findViewById(R.id.scatterChart);
    }
}